import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/global.css'
import './assets/fonts/iconfont.css'
// 引入vue-table-with-tree-grid
import TreeTable from 'vue-table-with-tree-grid'
// 富文本编辑器

import VueQuillEditor from 'vue-quill-editor'
// 富文本编辑器的样式
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
// 时间格式化
import moment from 'moment'

// moment插件
// Vue.filter('format', function (value) {
//   return moment(value).format('YYYY-MM-DD hh:mm:ss')
// })

Vue.filter('format', function (value) {
    const dt = new Date(value)

    const y = dt.getFullYear()
    const m = (dt.getMonth() + 1 + '').padStart(2, '0')
    const d = (dt.getDate() + '').padStart(2, '0')

    const hh = (dt.getHours() + '').padStart(2, '0')
    const mm = (dt.getMinutes() + '').padStart(2, '0')
    const ss = (dt.getSeconds() + '').padStart(2, '0')

    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

Vue.use(VueQuillEditor, /* { default global options } */)

// 导入进度条
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

// 请求拦截器
// 添加请求拦截器
axios.interceptors.request.use(config => {
    // 在发送请求之前做些什么
    NProgress.start()
    config.headers.Authorization = window.sessionStorage.getItem('token')
    return config;
});
// 响应拦截器
axios.interceptors.response.use(config => {
    // 在发送请求之前做些什么
    NProgress.done()

    return config;
});

axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/';
import axios from 'axios'

Vue.component('tree-table', TreeTable)

Vue.config.productionTip = false
Vue.prototype.$http = axios
new Vue({
    router,
    render: h => h(App)
}).$mount('#app')
